﻿sps.provide('sps.gis.supermap.Record');
sps.provide('sps.gis.supermap.Recordset');

sps.gis.supermap.Record = function () {
};

sps.gis.supermap.Record.prototype = {
    values: {},

    setValue: function (field, value) {
        this.values[field] = value;
    },

    fromSuperMapFeature: function (feature) {
        var record = new sps.gis.supermap.Record();
        var attributes = feature.attributes;
        for (var i = 0, len = attributes.fieldNames.length; i < len; i++) {
            record.values[attributes.fieldNames[i]] = attributes.fieldValues[i];
        }
        return record;
    },
};

sps.gis.supermap.Recordset = function() {

};

sps.gis.supermap.Recordset.prototype = {
  layerName:'',
  records:[],
  
  fromSuperMapRecordset:function(smRecordset) {
      var recordset = new sps.gis.supermap.Recordset;
	recordset.layerName(smRecordset.datasetName);
	var records = [];
	var features = smRecordset.features;
	for ( var i = 0, len1 = features.length; i < len1; i++) {
		var record = sps.gis.supermap.Record.fromSuperMapFeature(features[i]);
		records.push(record);
	}
	recordset.records = records;
	return recordset;
  }
};